---
sidebar_position: 6
description: Azure monitor Integration on Hasura Cloud
title: 'Cloud: Azure Monitor Integration'
keywords:
  - hasura
  - docs
  - cloud
  - metrics
  - integration
  - export logs
  - azure monitor
sidebar_label: Azure Monitor
---

import Thumbnail from '@site/src/components/Thumbnail';
import HeadingIcon from '@site/src/components/HeadingIcon';
import ProductBadge from '@site/src/components/ProductBadge';

# Azure Monitor Integration on Hasura Cloud

<ProductBadge pro ee />

## Introduction

:::caution Deprecation

Hasura Cloud observability integrations are deprecated in favour of using
[OpenTelemetry exporter](/observability/opentelemetry/index.mdx) to get advanced traces, metrics and logs.

:::

You can export metrics, operation logs and traces of your Hasura Cloud project to
[Azure Monitor](https://azure.microsoft.com/en-in/services/monitor/). This can be configured on the integrations tab on
the project's setting page.

:::info Note

For Hasura Cloud projects, the Azure Monitor Integration is only available on the `Standard` (pay-as-you-go) tier and
above.

:::

## Pre-requisites

- Create a
  [Service Principal](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#register-an-application-with-azure-ad-and-create-a-service-principal)
  in Azure.

- From the `Overview` tab of the created Service principal, retrieve `Application (client) ID` (Referred as
  `Active Directory Client ID` in this context) and `Directory (tenant) ID` (Referred as `Active Directory Tenant ID` in
  this context)

  <Thumbnail
    src="/img/observability/service-principal-properties.png"
    alt="Service Principal Properties"
    width="1146px"
  />

- From the `Certificates & secrets` tab of the created service principal, Create a client secret by clicking
  `New client secret`. Add a suitable description and expiry period for the secret and click `Add`. Copy the value of
  the created secret (Referred to as `Active Directory Client Secret` in this context)

  <Thumbnail src="/img/observability/service-principal-secret.png" alt="Service Principal Secret" width="1146px" />

- Create a [Log Analytics Workspace](https://docs.microsoft.com/en-us/azure/azure-monitor/logs/quick-create-workspace)
  in Azure.

- From the `Agents management` tab of the created log analytics workspace, retrieve `Workspace ID` and `Primary Key`
  (Referred as `Shared Key` in this context).

  <Thumbnail
    src="/img/observability/log-analytics-workspace-config.png"
    alt="Log Analytics workspace config parameters"
    width="1146px"
  />

- From the `Properties` tab of the created log analytics workspace, retrieve `Resource ID` and `Location` (Referred to
  as `Region` in this context)

  <Thumbnail src="/img/observability/log-analytics-properties.png" alt="Log Analytics Properties" width="1146px" />

- Assign the Role `Monitoring Metrics Publisher` to the Service principal against the Log analytics workspace. From the
  `Access control (IAM)` tab of the created log analytics workspace, Click on `Add` and select `Add role assignment`. In
  the Add role assignment panel, Select the Role as `Monitoring Metrics Publisher` and select the created service
  principal for role assignment and click `Save`.

  <Thumbnail src="/img/observability/service-principal-role.png" alt="Service Principal Role" width="1146px" />

- Create an
  [Application Insights resource](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource>) in
  Azure.

- From the `Overview` tab of the created Application Insights resource, retrieve `Instrumentation Key`

  <Thumbnail src="/img/observability/azure-instrumentation-key.png" alt="Instrumentation Key" width="1146px" />

## Configure Azure Monitor integration

On the Project settings page, navigate to **Integrations > Azure Monitor**.

<Thumbnail
  src="/img/observability/integrate-azure-monitor.png"
  alt="Configure Azure Monitor Integration"
  width="1146px"
/>

Enter the values of config parameters obtained from the steps in pre-requisites in the Azure monitor integration form.
In addition to the above parameters, the following fields are also needed:

| Field                                                                                                          | Description                                                                                                                                                      |
| -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Namespace](https://docs.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-custom-overview#namespace) | Namespaces are a way to categorize or group similar metrics together.                                                                                            |
| [Log type](https://docs.microsoft.com/en-us/azure/azure-monitor/logs/data-collector-api#request-headers)       | The record type of the log that is being submitted. It can contain only letters, numbers, and the underscore (\_) character, and it can't exceed 100 characters. |
| Custom Attributes **(Optional)**                                                                               | Custom Attributes associated with your logs. A default source tag `hasura-logs` is added to all exported logs.                                                   |

After adding appropriate values in the Azure monitor Integration panel, click `Connect Integration`.

## Checking the status of the integration

The green/red dot signifies the status of the integration. For each of the telemetry types (logs, metrics, traces) green
signifies successful exporting of the telemetry to Azure monitor. `Last Exported` is continuously updated, indicating
the timestamp of the last telemetry (log, metric, trace) successfully exported to your Azure monitor dashboard.

<Thumbnail
  src="/img/observability/configure-azure-monitor-done.png"
  alt="Azure monitor Integration successfully configured"
  width="1146px"
/>

In case of error while exporting any of telemetries(logs, metrics, traces) to Azure monitor, the dot becomes red and the
error messages/instructions are displayed. Click `Update Settings` button to update the config parameters.

<Thumbnail
  src="/img/observability/configure-azure-monitor-fail.png"
  alt="Azure monitor Integration unable to push logs"
  width="1146px"
/>

## View metrics

The integration exports the following five metrics to Azure monitor:

| Metric Exported                | Metric Name in Azure monitor  |
| ------------------------------ | ----------------------------- |
| Average number of requests     | `average_requests_per_minute` |
| Average request execution time | `average_execution_time`      |
| Success rate of requests       | `success_rate`                |
| Active subscriptions           | `active_subscriptions`        |
| Number of websockets open      | `websockets_open`             |

Non-zero values of all the above metrics are exported over a minute time interval.

To navigate to
[Azure monitor metrics dashboard](https://portal.azure.com/#blade/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/metrics)
,click `View Metrics`.

<Thumbnail
  src="/img/observability/azure-monitor-view-metrics.png"
  alt="Azure monitor Integration successfully configured"
  width="1146px"
/>

From the `Select a scope` panel, expand the resource group which contains the `Log analytics workspace` and select it
and click `Apply`. In the filter menu, select the correct namespace and `Add filter` to view the individual metric.

<Thumbnail
  src="/img/observability/azure-monitor-metrics.png"
  alt="Metrics successfully exported to Azure monitor"
  width="1146px"
/>

## View logs

To navigate to
[Azure monitor logs dashboard](https://portal.azure.com/#blade/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/logs),
click `View Logs`.

<Thumbnail
  src="/img/observability/azure-monitor-view-logs.png"
  alt="Azure monitor Integration successfully configured"
  width="1146px"
/>

From the `Select a scope` panel, expand the resource group which contains the `Log analytics workspace` and select it
and click `Apply`. The logs can be filtered using `Log type`. Use `{YOUR_LOG_TYPE}_CL` search parameter to filter the
logs. Custom log types are displayed in the left of the Query panel.

<Thumbnail
  src="/img/observability/azure-monitor-logs.png"
  alt="Logs successfully exported to Azure monitor"
  width="1146px"
/>

## View traces

To navigate to
[Azure monitor traces dashboard](https://portal.azure.com/#blade/Microsoft_Azure_Monitoring/AzureMonitoringBrowseBlade/applicationsInsights),
click `View traces`.

<Thumbnail
  src="/img/observability/azure-monitor-view-traces.png"
  alt="Application Insights Instrumentation Key"
  width="1146px"
/>

Select the appropriate `Application Insights` and click `Transaction search`. The traces can be filtered using `Trace`
and `Dependency` Event types. Clicking any of the `Dependency` result shows the `End-to-end transaction details` for the
corresponding trace.

<Thumbnail
  src="/img/observability/azure-monitor-trace-flame-graph.png"
  alt="Traces successfully exported to Azure monitor"
  width="1146px"
/>
